package org.javabeans;

import java.awt.Component;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyEditorSupport;

import javax.swing.JButton;

public class ImagePropertyEditor extends PropertyEditorSupport{
	private JButton jb=new JButton("AA");
	private Object oldValue;
	private PropertyChangeSupport propertyChangeSupport=new PropertyChangeSupport(this);
	private boolean addListener(PropertyChangeListener listener){
		propertyChangeSupport.addPropertyChangeListener( listener );
		return true;
	}
	@Override
	public Component getCustomEditor() {
		return jb;
	}
      @Override
    public boolean supportsCustomEditor() {
    	return true;
      }
      @Override
    public void setValue(Object value) {
    	propertyChangeSupport.firePropertyChange( "a" , oldValue , value );
    	this.oldValue=value;
    	super.setValue( value );
    }
      public ImagePropertyEditor() {
		 jb.addMouseListener( new MouseListener(){

			@Override
			public void mouseClicked(MouseEvent e) {
				setValue("new");
			}

			@Override
			public void mousePressed(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void mouseReleased(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void mouseExited(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}} );
      }
  }
